FORM | NN 2 IE 3 DOM 1 | ||||
The FORM object reflects the FORM element. The FORM object can be addressed in a reference either by the value assigned to its tag NAME attribute or by the index of the forms array contained by every document. To assemble a reference to a form control object, the FORM object must be part of the reference. This covers the eventuality that more than one form may be placed in a document. | |||||
HTML Equivalent<FORM> | |||||
Object Model Reference
|
action | NN 2 IE 3 DOM 1 | ||
Read/Write | |||
The URL to be accessed when a form is being submitted. Script control of this property lets one form be submitted to different server processes based on user interaction with the rest of the form. This property is read-only in IE 3. | |||
Exampledocument.entryForm.action = "http://www.megacorp.com/cgi-bin/altEntry" | |||
Value Complete or relative URL. | |||
|
encoding | NN 2 IE 3 DOM n/a | ||
Read/Write | |||
The MIME type for the data being submitted to the server with the form. For typical form submissions (where the METHOD attribute is set to post), the default value is the proper content type. But if you change the action property for a form by script, consider whether you require a custom encoding for the purpose. The DOM working draft indicates it may prefer to name this property encType to more closely mirror the tag attribute. Note that the encoding property is not modifiable in Internet Explorer 3. | |||
Exampledocument.orderForm.encoding = "text/plain" | |||
Value Case-insensitive MIME type (content type) value as a string. For multiple items, a comma-delimited list is allowed in a single string. | |||
|
length | NN 2 IE 3 DOM n/a | ||
Read-only | |||
The number of form elements in the form. | |||
Examplefor (var i = 0; i < document.forms[0].length; i++) ... } | |||
Value Integer. | |||
|
method | NN 2 IE 3 DOM 1 | ||
Read/Write | |||
Forms may be submitted via two possible HTTP methods: get and post. These methods determine whether the form element data is sent to the server appended to the ACTION attribute URL (get) or as a transaction message body (post). In practice, when the ACTION and METHOD attributes are not assigned in a FORM element, the form performs an unconditional reload of the same document, restoring form controls to their default values. Note that the method property is read-only in Internet Explorer 3. | |||
Exampledocument.entryForm.method = "post" | |||
Value Either of the following constant values as a string: get | post. | |||
|
name | NN 2 IE 3 DOM 1 | ||
Read/Write | |||
The identifier associated with the form. This information is not submitted with the form, but a form's name is used in references to the form and nested form elements. | |||
Examplevar firstFormName = document.forms[0].name | |||
Value Case-sensitive identifier that follows the rules of identifier naming: it may contain no whitespace, cannot begin with a numeral, and should avoid punctuation except for the underscore character. | |||
|
target | NN 2 IE 3 DOM 1 | ||
Read/Write | |||
The name of the window or frame that is to receive content returned by the server after the form is submitted. Such names are assigned to frames by the FRAME element's NAME attribute; for subwindows, the name is assigned via the second parameter of the window.open( ) method. | |||
Exampledocument.myForm.target = "_top" | |||
Value String value of the window or frame name, or any of the following constants (as a string): _parent | _self | _top | _blank. The _parent value targets the frameset to which the current document belongs; the _self value targets the current window; the _top value targets the main browser window, thereby eliminating all frames; and the _blank value creates a new window of default size. | |||
|
handleEvent( ) | NN 4 IE n/a DOM n/a | ||
handleEvent(event) Instructs the object to accept and process the event whose specifications are passed as the parameter to the method. The object must have an event handler for the event type to process the event. | |||
Returned Value None. | |||
Parameters
|
reset( ) | NN 3 IE 4 DOM n/a |
Performs the same action as a click of a reset-type input element. All form controls revert to their default values. | |
Returned Value None. | |
Parameters None. |
submit( ) | NN 2 IE 3 DOM n/a |
Performs the same action as a click of a submit-type input element. This method does not fire the onSubmit event handler in Navigator. | |
Returned Value None. | |
Parameters None. |
elements[ ] | NN 2 IE 3 DOM n/a |
Returns an array of all form control objects contained by the current form. | |
Syntaxdocument.forms[i].elements(index).objectPropertyOrMethod |